package com.demo.entity;

import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

/**
 * 用户表
 * @date 2021/4/30
 */
@Data
public class User implements UserDetails {
    private String username = "admin";
    private String password = "$2a$10$llkSGbcdgLYbC8J73TsqJeJosV6RGsxMYaR2V5k2p2Cn7tC8imW6m";
    private List<Role> roleList;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return roleList;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {
        return username;
    }

    @Override
    public boolean isAccountNonExpired() {
        //is啥的都是检验令牌啥的,无特殊操作全改为true就好
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        //判断是否被锁定false则抛出异常
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        //判断是否被禁用false则抛出异常
        return true;
    }
}
